package com.lzc.jobrecomendbackend.controller.profile;

import com.lzc.jobrecomendbackend.common.ApiResponse;
import com.lzc.jobrecomendbackend.model.profile.JobRecommendVO;
import com.lzc.jobrecomendbackend.model.profile.PageResult;
import com.lzc.jobrecomendbackend.model.profile.ProfileMatchRequest;
import com.lzc.jobrecomendbackend.model.profile.ProfileMatchVO;
import com.lzc.jobrecomendbackend.service.profile.ProfileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 个人画像控制器
 */
@RestController
@RequestMapping("/api/profile")
public class ProfileController {

    @Autowired
    private ProfileService profileService;
    
    /**
     * 获取个人与市场需求的匹配度
     * 
     * @param request 个人画像匹配请求
     * @return 匹配度结果
     */
    @PostMapping("/match")
    public ApiResponse<ProfileMatchVO> getProfileMatch(@RequestBody ProfileMatchRequest request) {
        ProfileMatchVO result = profileService.getProfileMatch(request);
        return ApiResponse.success(result);
    }
    
    /**
     * 获取个性化职位推荐
     * 
     * @param request 个人画像匹配请求（包含page和size参数）
     * @return 推荐职位分页结果
     */
    @PostMapping("/recommend")
    public ApiResponse<PageResult<JobRecommendVO>> getJobRecommendations(@RequestBody ProfileMatchRequest request) {
        // 从请求体中获取页码和每页大小
        int page = request.getPage() != null ? request.getPage() : 1;
        int size = request.getSize() != null ? request.getSize() : 10;
        
        PageResult<JobRecommendVO> result = profileService.getJobRecommendations(request, page, size);
        return ApiResponse.success(result);
    }
} 